﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace Volunteer
{
    public partial class WebForm5 : System.Web.UI.Page
    {
        private string ConnectionString = ConfigurationManager.ConnectionStrings["VolunteerDBConnectionString"].ConnectionString;
        private DBConn dbConn = new DBConn();

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            DateTime dtDateFrom = Convert.ToDateTime(txtDateFrom.Text);
            DateTime dtDateTo = Convert.ToDateTime(txtDateTo.Text);
            int VID = Convert.ToInt32(txtVID.Text);
            int CourtID = Convert.ToInt32(ddlCourtName.SelectedValue);
            string strJudgeName = txtJudgeName.Text.Trim();
            string[] strSplit = strJudgeName.Split(' ');

            string strJFName = strSplit[0];
            string strJLName = strSplit[1];

            TimeSpan diffResult = dtDateTo - dtDateFrom;
            Double HoursWorked = diffResult.TotalHours;
            
            try
            {
                dbConn.HoursWorked_Add(VID, dtDateFrom, dtDateTo, CourtID, strJFName, strJLName, HoursWorked);
                txtHoursWorked.Text = HoursWorked.ToString();
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
                trMessage.Visible = true;
            }
            
        }

        

    }
}
